package drawer1;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DrawingFrame extends JFrame{
	  public static void main(String args[]){
	        DrawingFrame drawFrame = new DrawingFrame();
                drawFrame.pack();
                drawFrame.setVisible(true);
       	}
	public DrawingFrame(){
		super("Drawing Application");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		JComponent drawingCanavas = createDrawingCanavas();
		add(drawingCanavas,BorderLayout.CENTER);
		JToolBar toolbar = createToolbar(drawingCanavas);
		add(toolbar,BorderLayout.NORTH);
	}

	private JComponent createDrawingCanavas(){
		JComponent drawingCanavas = new JPanel();
		drawingCanavas.setPreferredSize(new Dimension(400,300));
		drawingCanavas.setBackground(Color.white);
		drawingCanavas.setBorder(BorderFactory.createEtchedBorder());
		return drawingCanavas;
	}
	private JToolBar createToolbar(JComponent canvas){
		
		JToolBar toolbar = new JToolBar();
		JButton ellpseButton = new JButton("e");
		JButton squareButton = new JButton("s");
		JButton RectButton = new JButton("r");
		CanavasEditor cvedit = new CanavasEditor(ellpseButton);
		ellpseButton.addActionListener(cvedit);
		squareButton.addActionListener(cvedit);
		RectButton.addActionListener(cvedit);
		toolbar.add(RectButton);
		toolbar.add(squareButton);
		toolbar.add(ellpseButton);
		canvas.addMouseListener(cvedit);
		return toolbar;
	}
	
}
